# Maintainer: Martell Malone <martellmalone@gmail.com>

_realname=binwalk
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}") #"${MINGW_PACKAGE_PREFIX}-python2-${_realname}"
pkgver=2.0.1
pkgrel=2
pkgdesc="A tool for searching a given binary image for embedded files (mingw-w64)"
arch=('any')
url="http://binwalk.org"
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-zlib"
         "${MINGW_PACKAGE_PREFIX}-xz"
         "${MINGW_PACKAGE_PREFIX}-systre"
         "${MINGW_PACKAGE_PREFIX}-bzip2"
         #'tar'
         #'git'
         )
source=(${_realname}-${pkgver}.tar.gz::https://github.com/devttys0/${_realname}/archive/v${pkgver}.tar.gz)
sha256sums=('90ee8426d71e91b62dfe4a1446c457bc7835b475b28717859e275a0494403959')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  local pyt=${MINGW_PREFIX}/bin/python3
  sed -i "s|\$(PYTHON) ./setup.py install \$(PREFIX)|\$(PYTHON) ./setup.py install \"--prefix=${MINGW_PREFIX} --root=${pkgdir}\"|" Makefile.in
  autoconf
}

build() {
  cd "${srcdir}/${_realname}-${pkgver}"
  ./configure \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX}

  make
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"
  make DESTDIR="${pkgdir}" install
  install -m 644 -D "${srcdir}/${_realname}-${pkgver}/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
